<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('实际用料列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>材料名称：</label>-->
<!--                                <input type="text" name="cPname"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>材料数量：</label>-->
<!--                                <input type="text" name="cPnum"/>-->
<!--                            </li>-->
<!--                            <li hidden>-->
<!--                                <label>外键id：</label>-->
<!--                                <input type="text" name="cCid"/>-->
<!--                            </li>-->
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="pName"/>
                            </li>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:material:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:material:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:material:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:material:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:material:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:material:remove')}]];
        var prefixs = ctx + "ruoyi/material";
        var prefix = ctx + "system/building";
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefixs + "/add/{id}",
                exportUrl: prefixs + "/export",
                removeUrl: prefixs + "/remove",
                modalName:"",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                detailView: true,
                onExpandRow: function (index, row, $building) {
                    initChildTable(index, row, $building);
                },

                columns: [{
                    checkbox: true
                },
                    {
                        field: 'pId',
                        title: '项目id',
                        visible: false
                    },
                    {
                        field: 'pName',
                        title: '项目名称'
                    },
                    {
                        field: 'pTime',
                        title: '项目日期'
                    },
                    {
                        field: 'pFounder',
                        title: '项目经理'
                    },
                    // {
                    //     title: '操作',
                    //     align: 'center',
                    //     formatter: function(value, row, index) {
                    //         var actions = [];
                    //         actions.push('<a class="btn btn-success ' + creadFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.pId + '\')"><i class="fa fa-add"></i>添加</a> ');
                    //         return actions.join('');
                    //     }
                    // }
                ]
            };
            $.table.init(options);
        });
        initChildTable = function (index, row, $building) {

            var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: prefixs  + "/sId",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                queryParams: {
                    sId:row.pId
                },
                columns: [
                    {
                        field: 'cPid',
                        title: '实际用料id',
                        visible: false
                    },
                    {
                        field: 'cPname',
                        title: '材料名称'
                    },
                    {
                        field: 'cPnum',
                        title: '材料数量'
                    },
                    {
                        field: 'cCid',
                        title: '外键id',
                        visible: false
                    },
                    // {
                    //     title: '操作',
                    //     align: 'center',
                    //     formatter: function(value, row, index) {
                    //         var actions = [];
                    //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.cPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.cPid + '\')"><i class="fa fa-remove"></i>删除</a>');
                    //         return actions.join('');
                    //     }
                    // }
                    ]
            });
        };









        //
        // $(function() {
        //     var options = {
        //         url: prefixs + "/list",
        //         // createUrl: prefixs + "/add",
        //         // updateUrl: prefixs + "/edit/{id}",
        //         // removeUrl: prefixs + "/remove",
        //         // exportUrl: prefixs + "/export",
        //         modalName: "实际用料",
        //         columns: [{
        //             checkbox: true
        //         },
        //         {
        //             field: 'cPid',
        //             title: '实际用料id',
        //             visible: false
        //         },
        //         {
        //             field: 'cPname',
        //             title: '材料名称'
        //         },
        //         {
        //             field: 'cPnum',
        //             title: '材料数量'
        //         },
        //         {
        //             field: 'cCid',
        //             title: '外键id'
        //         },
        //         {
        //             title: '操作',
        //             align: 'center',
        //             formatter: function(value, row, index) {
        //                 var actions = [];
        //                 actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.cPid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
        //                 actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.cPid + '\')"><i class="fa fa-remove"></i>删除</a>');
        //                 return actions.join('');
        //             }
        //         }]
        //     };
        //     $.table.init(options);
        // });
    </script>
</body>
</html>